#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    //计算时间差值
    QDateTime timeOld=ui->dateTimeEdit->dateTime();
    QDateTime timeNew=ui->dateTimeEdit_2->dateTime();

    //int days=timeOld.daysTo(timeNew);
    int seconds=timeOld.secsTo(timeNew);
    int hours=(seconds/3600)%24;//天数剩余零头小时
    int days=seconds=(seconds/3600)/24;
    ui->label->setText("相距"+QString::number(days)+"天"+QString::number(hours)+"小时");
}
